<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	template="/pages/templates/template.xhtml">

	<ui:define name="meio">
		<ui:include src="menu.xhtml" />
	</ui:define>

	<ui:define name="centro">
		<div align="center">

			<h:form id="formnew">
				<p:commandButton id="selectButton" onclick="userNewDialog.show();"
					icon="ui-icon-person" value="Novo Funcionario" />
				<p:dialog header="Novo Funcionario" widgetVar="userNewDialog"
					resizable="false" id="userDlg" draggable="false" modal="true">
					<p:panelGrid columns="2">
						<h:outputText value="Nome" />
						<h:inputText value="#{newFuncMB.nomeFunc}" />

						<h:outputText value="Nome de Login" />
						<h:inputText value="#{newFuncMB.nomeUserFunc}" />

						<h:outputText value="E-mail" />
						<h:inputText value="#{newFuncMB.emailFunc}" />

						<p:commandButton value="ok" action="#{newFuncMB.adicionaFunc}"
							update=":formall" onclick="userNewDialog.hide();" ajax="false" />
						<p:commandButton type="reset" onclick="userNewDialog.hide();"
							value="cancel" />
					</p:panelGrid>
				</p:dialog>
			</h:form>
		</div>
		<div align="center">
			<h:form id="formall">

				<p:dataTable id="funcionarios" var="user"
					value="#{tabelaUserMB.funcs}">

					<p:column headerText="ID" style="width:24%">
						<h:outputText value="#{user.id}" />
					</p:column>

					<p:column headerText="Nome" style="width:72%">
						<h:outputText value="#{user.nome}" />
					</p:column>

					<p:column headerText="Nivel de Acesso" style="width:24%">
						<h:outputText value="#{user.nvlAcesso.acesso}" />
					</p:column>

					<p:column style="width:4%">
						<p:commandButton id="selectButton" update=":formall:display"
							onclick="userDialog.show();" icon="ui-icon-search" title="View">
							<f:setPropertyActionListener value="#{user}"
								target="#{tabelaUserMB.selectedUser}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>

				<p:dialog header="Funcionario Detalhes" widgetVar="userDialog"
					resizable="false" id="userDlg" draggable="false" modal="true">
					<p:panel id="display">
						<table>
							<tr>
								<td align="center" class="ui-widget-header" colspan="2"><h:outputText
										value="Atual" /></td>
								<td align="center" class="ui-widget-header"><h:outputText
										value="Novo" /></td>
							</tr>
							<tr>
								<td><h:outputText value="Nome de Login:" /></td>
								<td><h:outputText
										value="#{tabelaUserMB.selectedUser.nomeUsuario}"
										style="font-weight:bold" /></td>
								<td><h:inputText value="#{tabelaUserMB.nomeUserFunc}" /></td>
							</tr>

							<tr>
								<td><h:outputText value="Nome Completo:" /></td>
								<td><h:outputText value="#{tabelaUserMB.selectedUser.nome}"
										style="font-weight:bold" /></td>
								<td><h:inputText value="#{tabelaUserMB.nomeFunc}" /></td>
							</tr>

							<tr>
								<td><h:outputText value="E-mail:" /></td>
								<td><h:outputText
										value="#{tabelaUserMB.selectedUser.email}"
										style="font-weight:bold" /></td>
								<td><h:inputText value="#{tabelaUserMB.emailFunc}" /></td>
							</tr>

							<tr>
								<td><h:outputText value="Nivel de Acesso:" /></td>
								<td><h:outputText
										value="#{tabelaUserMB.selectedUser.nvlAcesso.acesso}" /></td>
								<td><h:selectOneMenu id="nvl" label="nvl"
										value="#{tabelaUserMB.acesso}"
										class="ui-selectonemenu-label ui-inputfield ui-corner-all">
										<f:selectItem itemLabel="Selecione um nivel de acesso."
											noSelectionOption="true" />
										<f:selectItems value="#{pageControl.nvlsAcesso}" var="n"
											itemLabel="#{n}" itemValue="#{n.id}" />

									</h:selectOneMenu></td>
							</tr>

							<tr>
								<td><h:commandButton value="ok"
										action="#{tabelaUserMB.alterarFunc}" /></td>
								<td><h:commandButton value="Resetar Senha"
										action="#{tabelaUserMB.resetarSenha}" /></td>
								<td><h:commandButton value="Cancelar"
										onclick="userDialog.hide()" type="reset" /></td>
							</tr>

						</table>
					</p:panel>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>

</ui:composition>
